package com.hy.study.controller;

import com.hy.study.utils.Result;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Scope;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author huyong
 * @date 2024 年 01 月 08 日 16:45: 08
 */

@Controller
@Scope("prototype")
public class EnvironmentController implements EnvironmentAware {
    private String javaHome;

    @Override
    public void setEnvironment(Environment environment) {
        javaHome = environment.getProperty("JAVA_HOME");
    }

    @GetMapping("javaHome")
    @ResponseBody
    public Result<String> getJavaHome() {
        return new Result<>(this.javaHome);
    }
}
